package com.ruoyi.common.utils.message;

import com.ruoyi.common.constant.ApiConstants;
import com.ruoyi.common.utils.message.HttpUtil;

public class MessageUntil {

    /*发送验证码短信*/
    public static int sendMessage(String phoneNum){
        int ran = (int) (Math.random() * 900000) + 100000;
        StringBuilder sb = new StringBuilder();
        sb.append("accountSid").append("=").append(ApiConstants.ACCOUNT_SID);
        sb.append("&to").append("=").append(phoneNum);
        sb.append("&param").append("=").append(ran+","+5);
        sb.append("&templateid").append("=").append(ApiConstants.YAN_ZHENG_MA);
        String body = sb.toString() + HttpUtil.createCommonParam(ApiConstants.ACCOUNT_SID, ApiConstants.AUTH_TOKEN);
        /*发送短信*/
        String result = HttpUtil.post(ApiConstants.BASE_URL, body);
        System.out.println(result);

        return ran;
    }
}
